package com.spark.gaea.security.utils;

import com.spark.gaea.security.domain.SecurityUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;

public class SessionUtil {
	public static String getUserId() {
		return (String) SecurityUtils.getSubject().getSession().getAttribute("userId");
	}

	public static SecurityUser getUser() {
		return (SecurityUser) SecurityUtils.getSubject().getSession().getAttribute("user");
	}

	public static Object get(final Object key) {
		return SecurityUtils.getSubject().getSession().getAttribute(key);
	}

	public static void set(final Object key, final Object value) {
		SecurityUtils.getSubject().getSession().setAttribute(key, value);
	}

	public static void remove(final Object key) {
		SecurityUtils.getSubject().getSession().removeAttribute(key);
	}

	public static Session getSession() {
		return SecurityUtils.getSubject().getSession();
	}
}
